<route lang="json5">
{
  style: {
    navigationBarTitleText: '工作详情',
  },
}
</route>

<template>
  <view class="common-container">
    <wd-form custom-class="common-form" ref="formRef" :model="formModel">
      <wd-cell-group>
        <!-- <wd-picker :columns="columns" label="填写月份" v-model="value" @confirm="handleConfirm" /> -->
        <wd-datetime-picker
          readonly
          type="year-month"
          v-model="formModel.dateCode"
          label="填写月份"
        />
        <wd-cell title="本月工作情况" :label="formModel.workLog"></wd-cell>
        <wd-cell title="下月工作计划" :label="formModel.nextWorkLog"></wd-cell>
      </wd-cell-group>
    </wd-form>
  </view>
</template>

<script setup>
import WorkApi from '@/service/work'
import dayjs from 'dayjs'

const initFormModel = {
  dateCode: '',
  type: 'month',
  workLog: '',
  nextWorkLog: '',
}

const formRef = ref()
const formModel = ref({
  dateCode: '',
  type: 'month',
  workLog: '',
  nextWorkLog: '',
})
const formKeyMap = {
  dateCode: '月份',
  workLog: '本月工作情况',
  nextWorkLog: '下月工作计划',
}

const getWorkDetail = async (id) => {
  const params = { id }
  const { code, result } = await WorkApi.getWorkDetail(params)
  if (code === 200 && result) {
    const dateCode = dayjs(result.dateCode).valueOf()
    formModel.value = { ...result, dateCode }
  }
}

onLoad((options) => {
  if (options.id) {
    getWorkDetail(options.id)
  }
})
</script>

<script>
export default {
  options: {
    styleIsolation: 'shared',
  },
}
</script>

<style lang="scss">
@import '../../../style/common-form';
</style>
